package com.aaa.service.impl;

import com.aaa.entity.Praise;
import com.aaa.mapper.PraiseMapper;
import com.aaa.service.IPraiseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Bean
 * @since 2021-09-05
 */
@Service
public class PraiseServiceImpl extends ServiceImpl<PraiseMapper, Praise> implements IPraiseService {

    @Autowired
    PraiseMapper praiseMapper;
    @Autowired
    NettyPushServerImpl nettyPushServer;

    public boolean add(Integer vid,Integer id,Integer uid,String uname){
        if(praiseMapper.add(vid,uid,id==uid?null:0)==1){
            if(id!=uid) {
                nettyPushServer.pushidServer(id.toString(), uname + "给小主作品点赞啦~");
            } return true;
        }else{
            return false;
        }
    }
}
